﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using DeVetma.admin.classes;
using DeVetma.admin.models.database.metadata;
using DeVetma.admin.models.managers;

namespace DeVetma.admin.models.entities
{
    [Entity(table="Member")]
    public class Member
    {
        [EntityField(column = "mUsername", keyField = true, nullValue = null)]
        public string mUsername { get; set; }

        [EntityField(column = "mFName", keyField = false, nullValue = null)]
        public string mFName { get; set; }

        [EntityField(column = "mLName", keyField = false, nullValue = null)]
        public string mLName { get; set; }

        [EntityField(column = "mGender", keyField = false, nullValue = null)]
        public string mGender { get; set; }

        [EntityField(column = "mEmail", keyField = false, nullValue = null)]
        public string mEmail { get; set; }

        [EntityField(column = "mAdd", keyField = false, nullValue = null)]
        public string mAdd { get; set; }

        [EntityField(column = "mTel", keyField = false, nullValue = null)]
        public string mTel { get; set; }

        [EntityField(column = "mActivationCode", keyField = false, nullValue = null)]
        public string mActivationCode { get; set; }

        [EntityField(column = "mActivationStatus", keyField = false, nullValue = null)]
        public string mActivationStatus { get; set; }

        public User user
        {
            get { return getUser(); }
            set { this.mUsername = value.uUsername; }
        }

        private User getUser()
        {
            return new UserManager().get(this.mUsername);
        }

        public override bool Equals(object obj)
        {
            if (obj is Member && ((Member)obj).mUsername == mUsername)
                return true;

            return false;
        }
    }
}